<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>12_节流-源码</title>
    </head>
    <body style="height: 3000px;">
        <script>


            function move(){
                console.log('摔死吧');
            }


            function throttle(func,time){
                var t1 = 0;//初始时间
                return function(){
                    var t2 = new Date();
                    if(t2 - t1 > time){
                        func();
                        t1 = t2;
                    }
                }
            }

            document.addEventListener('mousewheel',throttle(move,2000))

        </script>
    </body>
</html>